# $Id$
# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=system-config-printer
pkgver=1.5.9
pkgrel=3
pkgdesc="A CUPS printer configuration tool and status applet"
url="https://github.com/zdohnal/system-config-printer"
arch=('i686' 'x86_64')
license=('GPL')
depends=('python-pycups' 'python-dbus' 'python-pycurl' 'libnotify'
         'python-requests' 'python-gobject' 'gtk3' 'python-cairo')
makedepends=('intltool' 'xmlto' 'docbook-xsl' 'desktop-file-utils')
optdepends=(#'libgnome-keyring: password management'
            'python-pysmbc: SMB browser support'
            'cups-pk-helper: PolicyKit helper to configure cups with fine-grained privileges')
#source=(http://cyberelk.net/tim/data/${pkgname}/${pkgver%*.*}/${pkgname}-${pkgver}.tar.xz{,.sig})
source=(https://github.com/zdohnal/system-config-printer/archive/v${pkgver}.tar.gz
		pass_libgnome_keyring_missing.diff)
sha256sums=('c8adf4468a465a2640ac365498f551e8a8645a09027e24004fd390e40b6262e3'
            '7d901711ca8fd0470342bc03bf4458fb2552cebdfa141acb435b99cfde4d2621')
#validpgpkeys=('02EA6349CE58E1BCAA8514F57955128DA3A1ABD3' #Tim Waugh <twaugh@redhat.com> <tim@cyberelk.net>
#              '4629AFE960EC20BEC12E3104B7C20D079491EA63') #Tim Waugh <tim@cyberelk.net>

prepare() {
  cd ${pkgname}-${pkgver}
  
  # make it actually work without libgnome-keyring
  # https://bugs.archlinux.org/task/52607, https://github.com/zdohnal/system-config-printer/issues/51
  patch -Np1 -i ../pass_libgnome_keyring_missing.diff
  
  touch README ChangeLog
  autoreconf -fi
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-udevdir=/usr/lib/udev --with-udev-rules 
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  # Compile *.pyc
  find "${pkgdir}" -name '*.py' -exec python -mpy_compile {} +
  # Compile *.pyo
  find "${pkgdir}" -name '*.py' -exec python -O -mpy_compile {} +
  
  # new cups 2.0.0 service naming
  sed -i "s|cups.socket|org.cups.cupsd.socket|g" ${pkgdir}/usr/lib/systemd/system/configure-printer@.service
}
